/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core.file;

import enviro.Dungeon;
import java.io.*;

/**
 *
 * @author timon
 */
public class FileWriter {

    // <editor-fold defaultstate="collapsed" desc="API">
    /**
     * Save a dungeon to a file.
     * 
     * @param dungeon
     *   The dungeon to be saved in secondary storage.
     * @param path
     *   The path to which this file will be written.
     * @throws FileNotFoundException
     *   Thrown when a given file cannot be found 
     * @throws IOException 
     *   Thrown when the operation cannot be performed due to an i/o error.
     */
    public static void saveDungeon(Dungeon dungeon, String path) throws FileNotFoundException, IOException {
        
        // Create the stream to write into
        FileOutputStream fos = new FileOutputStream(path);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        
        // Write out the dungeon to the file
        oos.writeObject(dungeon);
        
        // Close the streams
        oos.close();
        fos.close();
    }
    // </editor-fold>
}
